home *** CD-ROM | disk | FTP | other *** search
/ PC Media 2 / PC MEDIA CD02.iso / share / prog / tpsorts / nwsfx.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-03-12  |  1.9 KB  |  73 lines

  1. {$c-}
  2. program WSfixer(input,output);
  3.  
  4.  
  5. {
  6.                            version 1.1
  7.  
  8. This  is  an  example of how to redirect input and  output  using 
  9.  
  10. Turbo Pascal.   Those of you who may have purchased 'Turbo Tutor' 
  11.  
  12. and found that the program titled 'FILTER.PAS' does'nt,  will  be 
  13.  
  14. happy to know that this program DOES!!
  15.  
  16. In  this example,  the program will redirect or filter any  file, 
  17.  
  18. converting a 'Wordstar' document file into a standard text file.
  19.  
  20. This new version is much faster; it processes up to 32k with only 
  21.  
  22. one  disk  access.   Also,  the input-output routines  have  been 
  23.  
  24. placed in their own 'included' file.
  25.  
  26.  
  27. If there are problems with this program call me:
  28.     Ken Kaplan
  29.     213-596-8635 (ans. machine)
  30.  
  31. Try typing '>A:NWSFX <WSFILE.DOC >TXTFILE.DOC'...and have fun!
  32.  
  33. copyright (c) 1985 Renaissance Software
  34. }
  35.  
  36. const
  37.      buffsize=$7fff;
  38.  
  39. type
  40.     aptr     =^data;
  41.     data     =record
  42.                     dta:array[1..buffsize] of byte;
  43.               end;
  44.  
  45.  
  46. var
  47.  
  48.    error,i,
  49.    bytes     :integer;
  50.    done      :boolean;
  51.    dtaptr    :aptr;
  52.  
  53. {$i stand_io.inc}
  54.  
  55. begin
  56.      repeat
  57.            done:=false;
  58.            i:=1;
  59.            new(dtaptr);
  60.            bytes:=buffsize;
  61.            with dtaptr^ do begin
  62.                 stdread(bytes,error,seg(dta),ofs(dta));
  63.                 if error<>$01 then begin
  64.                 repeat
  65.                       if (dta[i]>$7f) then
  66.                          dta[i]:=(dta[i] and $7f);
  67.                       i:=i+1;
  68.                 until ((dta[i]=26) or (i=buffsize+1));
  69.                 stdwrite(bytes,error,seg(dta),ofs(dta));
  70.                 end
  71.                 else
  72.                     done:=true;
  73.            end;
  74.      until done;
  75.      dispose(dtaptr);
  76. end.
  77.  
  78.  
  79.